<template>
	<view class="flist">
		<view @click="goForum(item.articleId)" class="flist-item" v-for="(item,fkey) in pageData" :key="fkey">
			<view class="flist-user">
				<image :src="item.img" class="flist-head"></image>
				<view class="flex-1">
					<view class="flist-nick">{{item.user}}</view>
					<view class="flist-time">{{item.dateTime}}</view>
				</view>
			</view>
			<view class="flist-title">{{item.title}}</view>

			<view class="flist-vd" v-if="item.videourl">
				<image class="flist-vd-bg" :src="item.videoimg"></image>
				<view class="flist-vd-play"></view>
			</view>

			<view class="flist-vd" v-else-if="item.imgArray.length == 1">
				<image class="flist-vd-bg" :src="item.imgArray[0].image" mode="widthFix"></image>

			</view>

			<view class="tui-flex" v-if="item.imgArray.length > 1">
				<view class="tui-center" v-for="(img, index) in item.imgArray" :key="index">
					<image :src="img.image" mode="widthFix"></image>
				</view>
			</view>

			<!-- <view class="flex flist-ft">
				<view class="flist-ft-love">
					{{item.love_num}} </view>
				<view class="flist-ft-cm">
					{{item.comment_num}} </view>
				<view class="flist-ft-view">
					{{item.view_num}} </view>
			</view> -->
		</view>

	</view>
</template>

<script>
	export default {
		components: {

		},
		data: function() {
			return {
				pageData: []
			}

		},
		onLoad: function(option) {
			// #ifndef H5
			uni.showShareMenu({
				showShareItems : ['qq', 'qzone', 'wechatFriends', 'wechatMoment']	
			});
			// #endif
			
			this.getPage();
		},
		onReachBottom: function() {
			this.getPage();
		},
		onPullDownRefresh: function() {
			this.refresh();
		},
		onNavigationBarButtonTap(e) {
			// 发帖
			if (e.float == "right") {
				//this.$tools.share.shareUrl();
				uni.navigateTo({
					url:'posting'
				})
			}
		},
		methods: {
			async getPage() {
				let res = await this.$api.articleList();
				this.pageData = res.data;
				console.log(this.pageData)
				this.pageData.forEach(item => {
					console.log(item.imgArray.length)
				})
			},
			goForum: function(id) {
				uni.navigateTo({
					url: "detail?id=" + id
				})
			},
			refresh: function() {
				this.getPage();
				setTimeout(function() {
					uni.stopPullDownRefresh();
				}, 1000)
			},
			loadMore: function() {
				this.getPage();
			}
		},
	}
</script>

<style lang="scss" scoped>
	@import "../../common/forum.css";
	.tui-flex{
		flex-wrap: wrap;
	}
	.tui-center{
		align-items: center;
		border: solid 1px #f1f1f1;
		width: 200upx;
		margin: 10upx;
	}
</style>
